Skip to content

Conversation

0xAX
Copy link
Contributor

@0xAX 0xAX commented Oct 8, 2021

Previously ecto_sql used pre-defined cache_statement value for all
types of queries. This commit adds ability to use user specified
cache statement as it could improve performance in certain situations
like multiple insert_all queries with fixed size batch and so on.

Besides this the commit adds length of parameters to the default
cache_statement name. In other way set of queries like this:

App.Repo.insert(%MyModel{name: "test_1", field_id: nil})
App.Repo.insert(%MyModel{name: "test_2", field_id: "test"})
App.Repo.insert(%MyModel{name: "test_3", field_id: nil})

will lead to situation when the previous prepared statement will be
closed when next query from the set will be executed and new one will
be created because nil values are not get into resulted query.

@0xAX
Copy link
Contributor Author

0xAX commented Oct 8, 2021

@josevalim I checked tests/ and not sure what kind of tests cases to add for the PR. Let me know please what should be added if need and I'll update the PR after the weekends

Previously ecto_sql used pre-defined cache_statement value for all
types of queries. This commit adds ability to use user specified
cache statement as it could improve performance in certain situations
like multiple `insert_all` queries with fixed size batch and so on.

Besides this the commit adds length of parameters to the default
cache_statement name. In other way set of queries like this:

    App.Repo.insert(%MyModel{name: "test_1", field_id: nil})
    App.Repo.insert(%MyModel{name: "test_2", field_id: "test"})
    App.Repo.insert(%MyModel{name: "test_3", field_id: nil})

will lead to situation when the previous prepared statement will be
closed when next query from the set will be executed and new one will
be created because `nil` values are not get into resulted query.
@0xAX 0xAX force-pushed the improve-cache-statement branch from b1ea830 to 4cbad16 Compare October 8, 2021 17:17
@josevalim josevalim merged commit 4013ecb into elixir-ecto:master Oct 8, 2021
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants